package jianzhiOffer;

import java.util.Deque;
import java.util.LinkedList;


class ListNode {
     int val;
     ListNode next;
      ListNode(int x) { val = x; }
  }
public class num06 {
    public int[] reversePrint(ListNode head) {
        Deque<Integer> stack = new LinkedList<>();
        ListNode node = head;
        int len = 0;
        while(node != null) {
            stack.push(node.val);
            node = node.next;
            len ++;
        }
        int[] arr = new int[len];
        for(int i = 0;i < len;i ++) {
            arr[i] = stack.pop();
        }
        return arr;
    }
}
